package edu.tec.mty.core.connection;

import edu.tec.mty.core.*;

public class Reader implements Runnable {

	private Connect connect;
	private boolean isAlive;
	private Information information;
	//private Logger logger;
	
	public Reader(Connect connect, Information information, int number) {
		this.connect = connect;
		this.isAlive = true;
		this.information = information;
		//this.logger = new Logger("player" + Integer.toString(number));
	}
	
	public void shutdown() {
		this.isAlive = false;
	}
	
	public void run() {
		while (this.isAlive) {
			String message = this.connect.receiveMessage();
			//System.out.println(message);
			//this.logger.insert(message);
			if (!message.equals("Error")) {
				this.information.processMessage(message);
			} /*else {
				this.isAlive = false;
			}*/
		}
		//this.logger.close();
		System.out.println("Reader closed");
	}
	
}
